#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
#include <stdio.h>
#include <string.h>
void finder(char path[], char target[]){
	DIR *d;
	struct dirent *de;
	struct stat buf;
	int exists;

	d = opendir(path);
	if(NULL == d){
		perror("prsize");
		exit(1);
	}

	while(NULL != (de=readdir(d))){
		char tmp[1000];
		if( strcmp(de->d_name, ".")==0 || strcmp(de->d_name, "..")==0 ) continue;
		sprintf(tmp, "%s\\%s", path, de->d_name);
		exists = stat(tmp, &buf);
		if(exists < 0){
			printf("Couldn't stat %s\n", tmp);
		}else{
			if( buf.st_mode & S_IFDIR ){
				sprintf(tmp, "%s", tmp);
				finder( tmp, target );
			}else{
				if( strcmp(de->d_name, target)==0 ){
					printf("%s\\%s\n", path, de->d_name);
				}
			}
		}
	}
	closedir(d);
}
int main(int argc, char** argv){
	if( argc!=3 ){
		printf("Parameter error!");
	}else{
		finder(argv[1], argv[2]);
	}
	return 0;
} 
